import http from '@/utils/http'

const BASE_URL = '/asset/software/records'

export interface SoftwareRecordsResp {
  id: string
  code: string
  name: string
  description: string
  categoryId: string
  version: string
  producerId: string
  sn: string
  price: string
  purchaseDate: string
  expireDate: string
  counts: string
  distribution: string
  status: string
  createUser: string
  createTime: string
  updateUser: string
  updateTime: string
  createUserString: string
  updateUserString: string
  disabled: boolean
}
export interface SoftwareRecordsDetailResp {
  id: string
  code: string
  name: string
  description: string
  categoryId: string
  version: string
  producerId: string
  sn: string
  price: string
  purchaseDate: string
  expireDate: string
  counts: string
  distribution: string
  status: string
  createUser: string
  createTime: string
  updateUser: string
  updateTime: string
  createUserString: string
  updateUserString: string
}
export interface SoftwareRecordsQuery {
  name: string | undefined
  categoryId: string | undefined
  version: string | undefined
  producerId: string | undefined
  counts: string | undefined
  createUser: string | undefined
  createTime: string | undefined
  sort: Array<string>
}
export interface SoftwareRecordsPageQuery extends SoftwareRecordsQuery, PageQuery {}

/** @desc 查询软件列表 */
export function listSoftwareRecords(query: SoftwareRecordsPageQuery) {
  return http.get<PageRes<SoftwareRecordsResp[]>>(BASE_URL, query)
}

/** @desc 查询软件详情 */
export function getSoftwareRecords(id: string) {
  return http.get<SoftwareRecordsDetailResp>(`${BASE_URL}/${id}`)
}

/** @desc 新增软件 */
export function addSoftwareRecords(data: any) {
  return http.post(BASE_URL, data)
}

/** @desc 修改软件 */
export function updateSoftwareRecords(data: any, id: string) {
  return http.put(`${BASE_URL}/${id}`, data)
}

/** @desc 删除软件 */
export function deleteSoftwareRecords(id: string) {
  return http.del(BASE_URL, { ids: [id] })
}

/** @desc 导出软件 */
export function exportSoftwareRecords(query: SoftwareRecordsQuery) {
  return http.download(`${BASE_URL}/export`, query)
}
